
class my_driver extends uvm_driver#(my_transaction);
    `uvm_component_utils(my_driver)

    function new(string name = "my_driver", uvm_component parent = null);
       super.new(name, parent);
       `uvm_info("mydriver", "new is called", UVM_LOW);
   endfunction

   extern virtual task main_phase(uvm_phase phase);
    extern virtual task drive_encode(my_transaction tr);

 endclass



task my_driver::drive_encode(my_transaction tr);
  top_tb.polar_enc_data_in = {'b0, tr.polar_enc_data_in};
  //启动信号
  top_tb.polar_enc_start = 1;

  @(posedge top_tb.clk);
    top_tb.polar_enc_start = 0;

        //判断完成信号
  @(negedge top_tb.polar_enc_done);


  //`uvm_info("my_driver", $sformatf("data is drived %b", top_tb.polar_enc_data_out), UVM_LOW);

  @(posedge top_tb.clk);

endtask


task my_driver::main_phase(uvm_phase phase);
   //@(posedge top_tb.clk);
   //phase.raise_objection(this);
  `uvm_info("my_driver", "main_phase is called", UVM_LOW);

  while(!top_tb.rst_n)
    @(posedge top_tb.clk);

    //码率设置
  top_tb.polar_rate_sel = 0;

  while(1) begin
    seq_item_port.get_next_item(req);
    drive_encode(req);
    seq_item_port.item_done();
  end
   

   //phase.drop_objection(this);
endtask